package classes.view.component
{
	import com.d4p.custom.defaultButton.DefaultBtn;
	
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	
	public class ChoiceContainer extends MovieClip
	{
		
		private var _mode :String;

		public function ChoiceContainer()
		{
			super();
			this.mode  = "ox"; 

		}
		
		private function onChoiceClick (event : MouseEvent):void
		{
			
			//trace("button click >> "  + (event.target as MovieClip).name);
			//trace("button click >>" + this.getChildIndex(event.target as MovieClip) );
			dispatchEvent(new GameEvent(GameEvent.ANSWER_CLICK, this.getChildIndex(event.target as MovieClip)));
		}
		
		public function set mode  ($mode : String):void 
		{
			_mode  = $mode ;
			this.gotoAndStop(_mode); 
			
			var ptr : DefaultBtn;
			for(var i :uint = 0; i < this.numChildren ; i ++){
				ptr = this.getChildAt(i) as DefaultBtn;
				if(!ptr.hasEventListener(MouseEvent.CLICK))
					ptr.addEventListener(MouseEvent.CLICK, onChoiceClick); 
			}
			
		}
		
		public function get mode () : String
		{
			return _mode ;
		}
	}
}